import { request } from './index'

// 获得表格数据
export function GetListFnc (data: {type: number, pageNum: number, pageSize: number}) { 
  return request({
    url: `/categories?type=${data.type}&pageNum=${data.pageNum}&pageSize=${data.pageSize}`,
    method: 'get'
  })
}

// 获得级联选择器数据
export function GetCascaderFnc (data: {type: number}) { 
  return request({
    url: `/categories?type=${data.type}`,
    method: 'get'
  })
}

// 添加分类
export function AddCategoryFnc (data: any) { 
  return request({
    url: '/categories',
    method: 'post',
    data: data
  })
}

// 编辑分类名称
export function EditCategoryFnc (id: number, data: {cat_name: string}) { 
  return request({
    url: `/categories/${id}`,
    data: data,
    method: 'put'
  })
}

// 删除分类
export function DeleteCateogryFnc (id: number) {
  return request({
    url: `/categories/${id}`,
    method: 'delete'
  })
}

